package com.ruoyi.cmemetal.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.cmemetal.mapper.ZxHeatPreprocessMapper;
import com.ruoyi.cmemetal.domain.ZxHeatPreprocess;
import com.ruoyi.cmemetal.service.IZxHeatPreprocessService;

/**
 * HeatPreprocessService业务层处理
 *
 * @author zhangxu
 * @date 2021-12-31
 */
@Service
public class ZxHeatPreprocessServiceImpl implements IZxHeatPreprocessService
{
    @Autowired
    private ZxHeatPreprocessMapper zxHeatPreprocessMapper;

    /**
     * 查询HeatPreprocess
     *
     * @param id HeatPreprocess主键
     * @return HeatPreprocess
     */
    @Override
    public ZxHeatPreprocess selectZxHeatPreprocessById(Long id)
    {
        return zxHeatPreprocessMapper.selectZxHeatPreprocessById(id);
    }

    /**
     * 查询HeatPreprocess列表
     *
     * @param zxHeatPreprocess HeatPreprocess
     * @return HeatPreprocess
     */
    @Override
    public List<ZxHeatPreprocess> selectZxHeatPreprocessList(ZxHeatPreprocess zxHeatPreprocess)
    {
        return zxHeatPreprocessMapper.selectZxHeatPreprocessList(zxHeatPreprocess);
    }

    /**
     * 新增HeatPreprocess
     *
     * @param zxHeatPreprocess HeatPreprocess
     * @return 结果
     */
    @Override
    public int insertZxHeatPreprocess(ZxHeatPreprocess zxHeatPreprocess)
    {
        return zxHeatPreprocessMapper.insertZxHeatPreprocess(zxHeatPreprocess);
    }

    /**
     * 修改HeatPreprocess
     *
     * @param zxHeatPreprocess HeatPreprocess
     * @return 结果
     */
    @Override
    public int updateZxHeatPreprocess(ZxHeatPreprocess zxHeatPreprocess)
    {

        //修改热处理时长
        if(zxHeatPreprocess.getOverTime() != null && zxHeatPreprocess.getStartTime() != null ){
            long time = DateUtils.zxgetDatePoor(zxHeatPreprocess.getOverTime(), zxHeatPreprocess.getStartTime());
            zxHeatPreprocess.setHeatProcessTime(time);
        }

        return zxHeatPreprocessMapper.updateZxHeatPreprocess(zxHeatPreprocess);
    }

    /**
     * 批量删除HeatPreprocess
     *
     * @param ids 需要删除的HeatPreprocess主键
     * @return 结果
     */
    @Override
    public int deleteZxHeatPreprocessByIds(Long[] ids)
    {
        return zxHeatPreprocessMapper.deleteZxHeatPreprocessByIds(ids);
    }

    /**
     * 删除HeatPreprocess信息
     *
     * @param id HeatPreprocess主键
     * @return 结果
     */
    @Override
    public int deleteZxHeatPreprocessById(Long id)
    {
        return zxHeatPreprocessMapper.deleteZxHeatPreprocessById(id);
    }
}
